# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=('libunistring' 'libunistring-devel')
pkgver=0.9.6
pkgrel=1
pkgdesc="Library for manipulating Unicode strings and C strings."
url="http://www.gnu.org/software/libunistring/"
arch=('i686' 'x86_64')
license=('GPL')
depends=('msys2-runtime' 'libiconv')
makedepends=('libiconv-devel')
source=(ftp://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.gz
        libunistring-0.9.3-2.src.patch
        libunistring-0.9.3-msys2.patch)
md5sums=('dfae4ff5583649ed24d8f368f1d0543b'
         '341536a243f4219d962a60e12a53169d'
         'e674d91b2b9c9df0e5ee938c42759cf3')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p2 -i ${srcdir}/libunistring-0.9.3-2.src.patch
  patch -p1 -i ${srcdir}/libunistring-0.9.3-msys2.patch

  #cp -rf build-aux/snippet ${srcdir}/
  autoreconf -fi
  #mv -f ${srcdir}/snippet/* build-aux/snippet/
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --build=${CHOST} --prefix=/usr
  make
  make DESTDIR="${srcdir}/dest" install
}

package_libunistring() {
  install=${pkgname}.install
  groups=('libraries')

  mkdir -p ${pkgdir}/usr
  cp -rf ${srcdir}/dest/usr/bin ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_libunistring-devel() {
  pkgdesc="libunistring headers and libraries"
  groups=('development')
  options=('!staticlibs')
  depends=("libunistring=${pkgver}" "libiconv-devel")

  mkdir -p ${pkgdir}/usr
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
